import NumberView from "./NumberView";
import allVariableJs from "./allVariable";
import PlatformUtil from "./PlatformUtil";

cc.Class({
    extends: cc.Component,

    properties: {

         numberCompontent:NumberView,
         chargeBtn:cc.Node,
         shopBtn:cc.Node,
         shopScrollView:cc.Node,
         backBtn:cc.Button,
         exitView:cc.Node,
         exitClosebtn:cc.Node,
         closeBtn:cc.Button,
         thinkBtn:cc.Button,
         cancleBtn:cc.Button

    
    
    },

    onLoad () {

    },


    closeExit:function(){

        var changebig = cc.scaleTo(0.02,1.2);

        var that=this
        var finish = cc.callFunc(function(){
    
          var changesmail = cc.scaleTo(0.08,1.0);

          var smaillfinish=cc.callFunc(function(){

            that.exitView.active=false

          })

          var seq2 = cc.sequence(changesmail,smaillfinish)
          this.closeBtn.node.runAction(seq2)
       

       }, this);
    
       var seq = cc.sequence(changebig,finish)

       this.closeBtn.node.runAction(seq)
       

    },

    canCle:function(){

        var changebig = cc.scaleTo(0.2,1.1);

        var that=this
        var finish = cc.callFunc(function(){
    
          var changesmail = cc.scaleTo(0.1,1.0);

          var smaillfinish=cc.callFunc(function(){

            that.exitView.active=false

          })

          var seq2 = cc.sequence(changesmail,smaillfinish)
          this.cancleBtn.node.runAction(seq2)
       

       }, this);
    
       var seq = cc.sequence(changebig,finish)

       this.cancleBtn.node.runAction(seq)

    },

    sureExit:function(){
       

        var changebig = cc.scaleTo(0.2,1.1);

     
        var finish = cc.callFunc(function(){
    
          var changesmail = cc.scaleTo(0.1,1.0);

          var smaillfinish=cc.callFunc(function(){

            cc.director.loadScene("StartGame");

          })

          var seq2 = cc.sequence(changesmail,smaillfinish)
          this.thinkBtn.node.runAction(seq2)
       

       }, this);
    
       var seq = cc.sequence(changebig,finish)

       this.thinkBtn.node.runAction(seq)
     
       
    },

    backmainClick:function(){

        var changebig = cc.scaleTo(0.2,1.1);

        var finish = cc.callFunc(function(){
    
            var that=this
          var changesmail = cc.scaleTo(0.1,1.0);

          var smaillfinish=cc.callFunc(function(){

            
            if(allVariableJs.isPlaying){

                console.log("正在游戏当中")
                that.exitView.active=true
            
            }else{
            
                cc.director.loadScene("StartGame");
            
            }
          })

          var seq2 = cc.sequence(changesmail,smaillfinish)
          this.backBtn.node.runAction(seq2)
       

       }, this);
    
       var seq = cc.sequence(changebig,finish)

       this.backBtn.node.runAction(seq)
 
    },

    rechargeClick:function(){

        var changebig2 = cc.scaleTo(0.2,1.1);

        var finish = cc.callFunc(function(){
    
          var changesmail2 = cc.scaleTo(0.1,1.0);
          this.chargeBtn.runAction(changesmail2)
    
       }, this);
    
       var seq = cc.sequence(changebig2,finish)
    
        this.chargeBtn.runAction(seq)
        
       console.log("去充值")

       PlatformUtil.platform.exchangeStar()
    

    },

    gotoShopClick:function(){

        console.log("进入商城")

        var changebig2 = cc.scaleTo(0.2,1.1);

        var finish = cc.callFunc(function(){
    
          var changesmail2 = cc.scaleTo(0.1,1.0);
          this.shopBtn.runAction(changesmail2)
          this.shopScrollView.active=true

       }, this);
    
       var seq = cc.sequence(changebig2,finish)
    
        this.shopBtn.runAction(seq)

    

    },


    addCoinStarNumber:function(){
  
        allVariableJs.starNumber=allVariableJs.starNumber+1;
     
        this.numberCompontent.setText(allVariableJs.starNumber)

    },

    addMoreCoinStarNumber:function(){
  
        allVariableJs.starNumber=allVariableJs.starNumber+2;
     
        this.numberCompontent.setText(allVariableJs.starNumber)

    },



    minusStarNumber:function(){

        allVariableJs.starNumber=allVariableJs.starNumber-10;
        this.numberCompontent.setText(allVariableJs.starNumber)
        
    },

    start () {

  
    
    },

    // update (dt) {},
});
